<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

    <ui:define name="head">
        <style type="text/css">
            .col-label {
                width: 100px;
                text-align: right;
            }

            .col-label2 {
                width: 100px;
                text-align: right;
            }

            .col-input {
                width: 200px;
                text-align: left;
            }

            .col-95 {
                width: 95%;
            }

            .col-5 {
                width: 5%;
            }

        </style>
        <script type="text/javascript" language="javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                }
            }
        </script>
    </ui:define>
    <ui:define name="content">
        <div style="margin-left: 5px;">
            <p:tabView id="tabview" dynamic="true" cache="false" style="font-weight:normal;font-style:normal">
                <p:tab title="新增商户项目折扣">
                    <h:form>
                        <div id="cdtdiscount">
                            <p:growl id="msgs" showDetail="false" life="7000"/>
                            <p:panel style="margin-top:27px;align:right;" id="panel">
                                <h:panelGrid columns="2" columnClasses="col-95,col-5">
                                    <h:panelGrid columns="4" cellspacing="5"
                                                 columnClasses="col-label,col-input,col-label2,col-input">

                                        <h:outputLabel value="*项目:"/>
                                        <h:selectOneMenu value="#{cdtDiscountAction.discount.projid}"
                                                         style="width: 187px;">
                                            <f:selectItems value="#{cdtDiscountAction.projOptions}"/>
                                        </h:selectOneMenu>

                                        <h:outputLabel value="*商户:"/>
                                        <h:selectOneMenu value="#{cdtDiscountAction.discount.storeid}"
                                                         style="width: 187px;">
                                            <f:selectItems value="#{cdtDiscountAction.storeOptions}"/>
                                        </h:selectOneMenu>

                                        <h:outputLabel value="*折扣(%):"/>
                                        <p:inputText required="true" value="#{cdtDiscountAction.discount.discount}"
                                                     size="27"
                                                     maxlength="5" requiredMessage="必须输入折扣百分比！">
                                            <f:convertNumber pattern="###.##"/>
                                        </p:inputText>
                                    </h:panelGrid>
                                    <h:panelGrid columns="1" style="text-align: center;">
                                        <p:commandButton style="width:120px;align:center;" value="保存"
                                                         action="#{cdtDiscountAction.onInsert}"
                                                         update="msgs,panel,pdt">
                                        </p:commandButton>
                                    </h:panelGrid>
                                </h:panelGrid>
                            </p:panel>
                            <p:ajaxStatus style="height:18px;text-align:center">
                                <f:facet name="start">
                                    <h:graphicImage value="/images/ajaxloadingbar.gif"/>
                                </f:facet>
                                <f:facet name="complete">
                                    <h:outputText value=""/>
                                </f:facet>
                            </p:ajaxStatus>
                            <p:dataTable id="pdt" dynamic="true" style="width:100%;"
                                         value="#{cdtDiscountAction.discountList}" var="record"
                                         rowKey="#{record.pkid}"
                                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                         paginator="true" rows="15" paginatorPosition="bottom"
                                         rowsPerPageTemplate="100,50,30,15,5"
                                         emptyMessage="没有查询到数据记录...">
                                <p:column headerText="项目ID" style="text-align: center">
                                    <h:outputText value="#{record.projid}"/>
                                </p:column>
                                <p:column headerText="项目名称" style="text-align: left">
                                    <h:outputText value="#{cdtDiscountAction.projMap[record.projid]}"/>
                                </p:column>
                                <p:column headerText="商户ID" style="text-align: center">
                                    <h:outputText value="#{record.storeid}"/>
                                </p:column>
                                <p:column headerText="商户名称" style="text-align: left">
                                    <h:outputText value="#{cdtDiscountAction.storeMap[record.storeid]}"/>
                                </p:column>
                                <p:column headerText="折扣">
                                    <h:outputText value="#{record.discount * 100}%" style="float: right"/>
                                </p:column>

                            </p:dataTable>
                        </div>
                    </h:form>
                </p:tab>
            </p:tabView>
        </div>
    </ui:define>
</ui:composition>